<%--
  Created by IntelliJ IDEA.
  User: Dink
  Date: 2022/1/25
  Time: 13:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>APP修改页面</title>
</head>
<body>
<%@ include file="comment/header.jsp"%>
<div style="position: relative;left: 230px;top:-10px;width: 1270px">
    <div class="row">
        <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">
                <div class="x_content">
                    <form action="${pageContext.request.contextPath}/app_info/update" onsubmit="return regs();" class="form-horizontal form-label-left"  enctype="multipart/form-data" method="post" >
                        <p style="font-size: 20px"><span >APP信息修改
                                <span class="glyphicon glyphicon-user" aria-hidden="true"></span>
                            </span>
                        </p>
                        <input type="hidden" name="id" value="${app_info.id}">
                        <div class="clearfix"></div>
                        <div class="item form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">软件名称 <span class="required">*</span>
                            </label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <input id="name" value="${app_info.softwareName}" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="softwareName" placeholder="请输入软件名称" required="required" type="text">
                            </div>
                        </div>
                        <div class="item form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12">AKP名称 <span class="required">*</span>
                            </label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <input required="required" type="text"  value="${app_info.APKName}" name="APKName" placeholder="请输入APK名称"  class="form-control col-md-7 col-xs-12">
                            </div>
                        </div>
                        <div class="item form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12">支持ROM <span class="required">*</span>
                            </label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <input class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2"  value="${app_info.supportROM}" name="supportROM" placeholder="请输入支持的ROM" required="required" type="text">
                            </div>
                        </div>
                        <div class="item form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12">界面语言 <span class="required">*</span>
                            </label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <input  value="${app_info.interfaceLanguage}" name="interfaceLanguage" class="form-control col-md-7 col-xs-12">
                            </div>
                        </div>
                        <div class="item form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="website">软件大小 <span class="required">*</span>
                            </label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <input type="number" id="website" value="${app_info.softwareSize}" name="softwareSize" required="required" placeholder="请输入软件大小，单位为Mb" class="form-control col-md-7 col-xs-12">
                            </div>
                        </div>
                        <div class="item form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12" >下载次数 <span class="required">*</span>
                            </label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <input type="number"   value="${app_info.downloads}" name="downloads" required="required" placeholder="请输入下次数" class="form-control col-md-7 col-xs-12">
                            </div>
                        </div>
                        <div class="item form-group">
                            <label class="control-label col-md-3">所属平台<span class="required">*</span></label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <select name="flatformId" class="form-control col-md-7 col-xs-12">
                                    <c:forEach items="${flatform}" var="flatform">
                                        <option value="${flatform.valueId}"
                                            ${app_info.flatformId==flatform.valueId?'selected="selected"':''}
                                       >${flatform.valueName}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="item form-group">
                            <label class="control-label col-md-3">一级分类<span class="required">*</span></label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <input type="hidden" value="${app_info.categoryLevel1}" name="c1">
                                <select onclick="classifyOne(this.value)" name="categoryLevel1" class="form-control col-md-7 col-xs-12">
                                    <c:forEach items="${app_category1}" var="app_category1">
                                        <option value="${app_category1.id}"
                                            ${app_info.categoryLevel1==app_category1.id?'selected="selected"':''}
                                        >${app_category1.categoryName}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="item form-group">
                            <label class="control-label col-md-3">二级分类<span class="required">*</span></label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <input type="hidden" value="${app_info.categoryLevel2}" name="c2">
                                <select onchange="classifyTWO(this.value)" name="categoryLevel2" class="form-control col-md-7 col-xs-12">
                                </select>
                            </div>
                        </div>
                        <div class="item form-group">
                            <label class="control-label col-md-3">三级分类<span class="required">*</span></label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <input type="hidden" value="${app_info.categoryLevel3}" name="c2">
                                <select name="categoryLevel3" class="form-control col-md-7 col-xs-12">
                                </select>
                            </div>
                        </div>
                        <div class="item form-group">
                            <label  class="control-label col-md-3 col-sm-3 col-xs-12">APP状态<span class="required">*</span></label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <input type="text" readonly value="${app_info.statusName}" class="form-control col-md-7 col-xs-12">
                                <input type="hidden" readonly value="${app_info.status}" name="status" class="form-control col-md-7 col-xs-12">
                            </div>
                        </div>
                        <div class="item form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">应用简介 <span class="required">*</span>
                            </label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <textarea id="textarea"   required="required" name="appInfo" class="form-control col-md-7 col-xs-12">
                                    ${app_info.appInfo}
                                </textarea>
                            </div>
                        </div>
                        <div class="item form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12">LOGO图片 <span class="required">*</span>
                            </label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <img src="${app_info.logoLocPath}" width="50px" >
                                <a href="javascript:;" onclick="delimg(this);">删除</a>
                                <input type="file" name="file" data-validate-length-range="8,20" class="form-control col-md-7 col-xs-12">
                                <p id="regs"><span style="color: red">*注：1.大小不能超过500k 2.图片格式.gif,.jpg,.png</span></p>
                            </div>
                        </div>
                        <div class="ln_solid"></div>
                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-3">
                                <button type="submit" class="btn btn-primary">保存</button>
                                <a href="${pageContext.request.contextPath}/app_info/list">
                                    <button id="send" type="button" class="btn btn-success">返回</button></a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<%@ include file="comment/foot.jsp"%>
</body>
<script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/jquery.js"></script>
<script type="text/javascript">
    $(function () {
        $("[name=file]").hide();
        $("#regs").hide();
        var c2=$("[name=c2]").val();
        var c1=$("[name=c1]").val();
        var c3=$("[name=c3]").val();
        var options="";
        var options2="";
        $.getJSON('${pageContext.request.contextPath}/app_info/categroyleve1?id='+c1,function (data) {
            for (var i=0;i<data.length;i++){
             /*   if(data[i].id==c2){
                    options+='<option value="'+data[i].id+'"\n' +
                        '>'+data[i].categoryName+'</option>';
                }*/
                options+='<option value="'+data[i].id+'"\n' +
                    '>'+data[i].categoryName+'</option>';
            }
            $("[name=categoryLevel2]").append(options);
        });
        $.getJSON('${pageContext.request.contextPath}/app_info/categroyleve1?id='+c2,function (data) {
            for (var i=0;i<data.length;i++){
                if(data[i].id==c3){
                    options2+='<option value="'+data[i].id+'"\n' +
                        '>'+data[i].categoryName+'</option>';
                }
                options2+='<option value="'+data[i].id+'"\n' +
                    '>'+data[i].categoryName+'</option>';
            }
            $("[name=categoryLevel3]").append(options2);
        });
    });
    function classifyOne(categoryLeve) {
        $("[name=categoryLevel2]").html("");
        $.getJSON('${pageContext.request.contextPath}/app_info/categroyleve1?id='+categoryLeve,function (data) {
            var options='<option value="0">--请选择--</option>';
            for (var i=0;i<data.length;i++){
                options+='<option value="'+data[i].id+'"\n' +
                    '>'+data[i].categoryName+'</option>';
            }
            $("[name=categoryLevel2]").append(options);
        });
    }
    function classifyTWO(categoryLeve) {
        $("[name=categoryLevel3]").html("");
        var options='';
        $.getJSON('${pageContext.request.contextPath}/app_info/categroyleve1?id='+categoryLeve,function (data) {
            for (var i=0;i<data.length;i++){
                options+='<option value="'+data[i].id+'"\n' +
                    '>'+data[i].categoryName+'</option>';
            }
            $("[name=categoryLevel3]").append(options);
        });
    }
    function delimg(obj) {
        $("img").remove();
        $(obj).remove();
        alert("删除成功！");
        $("[name=file]").show();
        $("#regs").show();
    }
</script>
</html>
